<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="160px">
      <el-form-item label="一级返还佣金：" prop="firstReturnCommission">
        <el-input type="number" v-model="form.firstReturnCommission" placeholder="请输入">
          <template slot="append">%</template>
        </el-input>
      </el-form-item>
      <el-form-item label="二级返还佣金：" prop="firstReturnCommission">
        <el-input type="number" v-model="form.firstReturnCommission" placeholder="请输入">
          <template slot="append">%</template>
        </el-input>
      </el-form-item>
      <el-form-item label="单次最小提现金额：" prop="withdrawMinMoney">
        <el-input type="number" v-model="form.withdrawMinMoney" placeholder="请输入">
          <template slot="append">元</template>
        </el-input>
      </el-form-item>
      <el-form-item label="单次最大提现金额：" prop="withdrawMaxMoney">
        <el-input type="number" v-model="form.withdrawMaxMoney" placeholder="请输入">
          <template slot="append">元</template>
        </el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align: center">
      <el-button type="primary" @click="submitForm">保 存</el-button>
    </div>
  </div>
</template>

<script>
import { getExtendSettingInfo, saveExtendSetting } from "@/api/shuiyin/shuiyin";

export default {
  name: "RecommendSetting",
  props: {
    taskId: {
      type: String
    }
  },
  data() {
    return {
      uploadAction: process.env.VUE_APP_BASE_API + "/common/ossUpload",
      // 图文分享参数
      form: {},
      // 文件接收数组
      fileValue: [],
      rules: {
        title: [
          { required: true, message: "分享标题不能为空", trigger: "blur" }
        ],
        content: [
          { required: true, message: "分享内容不能为空", trigger: "blur" }
        ],
        pic: [
          { required: true, message: "上传图片不能为空", trigger: "change" }
        ],
        shareUrl: [
          { required: true, message: "分享链接不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getInfo();
  },
  methods: {
    /** 查询租户管理列表 */
    getInfo() {
      getExtendSettingInfo().then(response => {
        if (response.data) {
          this.form = response.data;
          this.fileValue = this.form.pic ? this.form.pic.split(',') : [];
        } else {
          this.form = {
            firstReturnCommission: '',
            secondReturnCommission: '',
            withdrawMinMoney: '',
            withdrawMaxMoney: ''
          }
        }
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          saveExtendSetting(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.getInfo();
          });
        }
      });
    }
  }
};
</script>
<style>

</style>
